package com.heima.admin.controller.v1;

import com.heima.admin.service.AdChannelService;
import com.heima.model.admin.dtos.ChannelDTO;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "频道管理", tags = "频道管理API")
//@Api(value = "频道管理", tags = "channel", description = "频道管理API")
public class AdChannelController {

    @Autowired
    private AdChannelService adChannelService;

    @PostMapping("/list")
    @ApiOperation(value = "频道分页列表查询")
    public ResponseResult findChannelByName(@RequestBody ChannelDTO channelDTO){
        return adChannelService.findChannelByName(channelDTO);
    }

    // 添加
    @PostMapping("/save")
    @ApiOperation("频道新增")
    public ResponseResult insertChannel(@RequestBody AdChannel adChannel){
        return adChannelService.insertChannel(adChannel);
    }

    // 修改
    @ApiOperation("频道修改")
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody AdChannel adChannel) {
        return adChannelService.updateChannel(adChannel);
    }

    // 删除
    @ApiOperation("根据频道ID删除")
    @GetMapping("/del/{id}")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adChannelService.deleteById(id);
    }
}
